<?php 
$this->load->view('layout/Header'); 
?>
    
    <div id="mainContent" class="floatFix">
        
    	<div class="lCol">
			<?php $this->load->view('public_bookings/links',$links_list); ?>
        	<?php $this->load->view('layout/flashdata'); ?>
            
           	<h2>Step 3 : Passengers details</h2>
			
			<?php echo validation_errors(); ?>
			
			<?php $passengers = $this->session->userdata("passengers"); ?>
            
            <form action="<?php echo site_url("public_bookings/step3"); ?>" method="post">
			
				<ul class="formContainer">			
			        <?php
					for ($i = 0; $i < $booking_number_passengers; $i++)
					{?>
						<li>
							<fieldset>
								<legend>Passenger <?php echo $i+1; ?></legend>
								
								<ul class="formContainer">
								
									<li class="floatFix">
										<label>First Name <span class="required">*</span></label> 
										<input type="text" name="booking_passenger_first_name[<?php echo $i; ?>]" id="booking_passenger_first_name[<?php echo $i; ?>]" value="<?php 
										if($i == 0) 
										{
											if(isset($passengers[$i]['first_name'])) echo set_value("booking_passenger_first_name[$i]", $passengers[$i]['first_name']); 
											else echo set_value("booking_passenger_first_name[$i]", $this->session->userdata('booking_first_name'));
										}
										else
										{
											if(isset($passengers[$i]['first_name'])) 
												echo set_value("booking_passenger_first_name[$i]", $passengers[$i]['first_name']);
											else 
												echo set_value("booking_passenger_first_name[$i]");	
										}
										?>" />
									</li>
									<li class="floatFix">
										<label>Last Name <span class="required">*</span></label>
										<input type="text" name="booking_passenger_last_name[<?php echo $i; ?>]" id="booking_passenger_last_name[<?php echo $i; ?>]" value="<?php  
										if($i == 0) 
										{
											if(isset($passengers[$i]['last_name']))echo set_value("booking_passenger_last_name[$i]", $passengers[$i]['last_name']);
											else echo set_value("booking_passenger_last_name[$i]", $this->session->userdata('booking_last_name'));
										}
										else
											if(isset($passengers[$i]['last_name']))
												echo set_value("booking_passenger_last_name[$i]", $passengers[$i]['last_name']);
											else	
												echo set_value("booking_passenger_last_name[$i]");
										?>" />										
										
									</li>
									<li class="floatFix">
										<label>Sex <span class="required">*</span></label>
										<?php 
										
											if($i == 0)
											{											
												if( (isset($passengers[$i]['sex'])) && ($passengers[$i]['sex'] == 'M') ) { $bool1 = TRUE; $bool2 = FALSE;}
												elseif( (isset($passengers[$i]['sex'])) && ($passengers[$i]['sex'] == 'F') ) { $bool1 = FALSE; $bool2 = TRUE;}
												elseif($this->session->userdata('booking_sex') == 'M') {$bool1 = TRUE; $bool2 = FALSE;}
												elseif($this->session->userdata('booking_sex') == 'F') {$bool1 = FALSE; $bool2 = TRUE; }																			
												else { $bool1 = TRUE; $bool2 = FALSE;}
											}
											else
											{
												if( (isset($passengers[$i]['sex'])) && ($passengers[$i]['sex'] == 'M') ) { $bool1 = TRUE; $bool2 = FALSE;}
												elseif( (isset($passengers[$i]['sex'])) && ($passengers[$i]['sex'] == 'F') ) { $bool1 = FALSE; $bool2 = TRUE;}
												else { $bool1 = TRUE; $bool2 = FALSE;}												
											}
										?>
										<input type="radio" class="radio" name="booking_passenger_sex[<?php echo $i; ?>]" id="booking_passenger_sex[<?php echo $i; ?>]" value="M" <?php echo set_radio('booking_passenger_sex['.$i.']', 'M', $bool1); ?> /> <div>M</div>
										<input type="radio" class="radio" name="booking_passenger_sex[<?php echo $i; ?>]" id="booking_passenger_sex[<?php echo $i; ?>]" value="F" <?php echo set_radio('booking_passenger_sex['.$i.']', 'F',$bool2); ?> /> <div>F</div>
									</li>    				
									<li class="floatFix">
										<label>Nationality <span class="required">*</span></label>
											<?php
											if (($i == 0) && (!isset($_POST["booking_passenger_nationality"][$i])))$select = $this->session->userdata('booking_nationality');
											elseif (($i == 0) && (isset($_POST["booking_passenger_nationality"][$i]))) $select = $_POST["booking_passenger_nationality"][$i];
											elseif ( ($i != 0) && (!isset($_POST["booking_passenger_nationality"][$i])) && (isset($passengers[$i]['nationality'])) ) $select =  $passengers[$i]['nationality'];
											elseif (($i != 0) && (isset($_POST["booking_passenger_nationality"][$i])) && (!isset($passengers[$i]['nationality'])) ) $select = $_POST["booking_passenger_nationality"][$i];
											elseif (($i != 0) && (!isset($_POST["booking_passenger_nationality"][$i])) && (!isset($passengers[$i]['nationality'])) ) $select =  "Scottish";
											echo dropdown_nationalities("booking_passenger_nationality[$i]",$select);
											?>	
									</li>            										
									<li class="floatFix">
										<label>Emergency phone number <?php if($i==0) echo '<span class="required">*</span>'; ?></label>
										<input type="text" name="booking_passenger_emergency[<?php echo $i; ?>]" id="booking_passenger_emergency[<?php echo $i; ?>]" value="<?php 
										if(isset($passengers[$i]['emergency_phone_number']))
											echo set_value("booking_passenger_emergency[$i]",$passengers[$i]['emergency_phone_number']);											
										else
											echo set_value("booking_passenger_emergency[$i]");

										?>" />											
 									</li>        									
								</ul>
							</fieldset>
						</li>
                    <?php } ?>
					<li class="floatFix">
                        <input type="submit" class="submitButton" value="Continue >>" name="go_to_step4" id="go_to_step4" />
                    </li>
				</ul>
			
             <form>
        
        </div>
        
        <div class="rCol">
        	<h2>Sidebar</h2>
        </div>
        
    </div>
    
<?php $this->load->view('layout/Footer'); ?>